﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace WttSync
{
    class CommandLineParameters
    {
        static CommandLineParameters()
        {
            string strCmd = System.Environment.CommandLine;

            m_regex_param = new Regex("/(?<key>[^ ]+)[ ]*:[ ]*((?<value>[^ ]+)|(\"(?<value>[^.]+)\"))", RegexOptions.IgnoreCase);
            m_params = new Dictionary<string, string>();

            Match match = m_regex_param.Match(strCmd);
            while (match.Success)
            {
                string key = match.Result("${key}");
                string value = match.Result("${value}");
                if (!m_params.ContainsKey(key))
                {
                    m_params.Add(key, value);
                }
                match = match.NextMatch();
            }
        }

        bool GetNamedParameter(string key, out string value)
        {
            return m_params.TryGetValue(key, out value);
        }

        private static Regex m_regex_param;
        private static Dictionary<string, string> m_params;
    }

    
     
}
